/*
 * Created on Sep 28, 2003
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package schoolsource.model;

import java.util.ArrayList;
import java.util.logging.Level;

import schoolsource.sql.SchoolDBSQL;
import schoolsource.util.SchoolLogger;

/**
 *
 * @author Steven Steele
 * Copyright 2003
 *
 * Contains information for a period on a single day.
 */
public class HourContainer extends Container {

	// The day of the week that the hour occurs
	private StringItem dayOfWeek =
		new StringItem(SchoolDBSQL.PERIODDAYOFWEEK, "", true);
	// The start time of the hour
	private TimeOfDayItem periodStartTime =
		new TimeOfDayItem(SchoolDBSQL.PERIODSTARTTIME, "", false);
	// The end time of the hour
	private TimeOfDayItem periodEndTime =
		new TimeOfDayItem(SchoolDBSQL.PERIODENDTIME, "", false);

	/**
	 *
	 *
	 */
	 public HourContainer() {

	 }

	/**
	 * Constructor creates an hour with the specified values
	 * @param newDayOfWeek The day of the week the hour occurs
	 * @param newPeriodStartTime The hour, minute, and second the class starts (HH:MM:SS)
	 * @param newPeriodEndTime The hour, minute, and second the class ends (HH:MM:SS)
	 */
	public HourContainer(String newDayOfWeek, String newPeriodStartTime, String newPeriodEndTime) {
		getDayOfWeek().setValue(newDayOfWeek);
		getPeriodStartTime().setValue(newPeriodStartTime);
		getPeriodEndTime().setValue(newPeriodEndTime);
	}

/*	public static HourContainer getHourContainer(String dayOfWeek, String dbName) {
		HourContainer returnVal = null;
		DBStore dbs = null;

		if (cID == "-1") {
			returnVal = new HourContainer();
		}
		else {
			if ((dbs = (DBStore) dbStores.get(dbName)) == null) {
				dbs = new DBStore();
				dbStores.put(dbName, dbs);
				dbs.start();
			}
			if ((returnVal = (HourContainer) dbs.getContainer(cID)) == null) {
				returnVal = new HourContainer();
				returnVal.getCourseAssignedID().setValue(cID);
				SchoolDBSQL.getSchoolDBSQL(dbName).loadCourse(returnVal.getValidationItems(), returnVal.getCourseAssignedID());
				dbs.addContainer(returnVal, cID);
			}
		}

		return returnVal;
	}*/

	/* (non-Javadoc)
	 * @see schoolsource.model.Container#getValidationItems()
	 */
	public Item[] getValidationItems() {
		ArrayList al = new ArrayList();
		al.add(dayOfWeek);
		al.add(periodStartTime);
		al.add(periodEndTime);

		return (Item[]) al.toArray(new Item[al.size()]);
	}

	/**
	 * Getter for the day of the week.
	 * @return The day of the week.
	 */
	public StringItem getDayOfWeek() {
		return dayOfWeek;
	}

	/**
	 * Getter for the period start time on the day of the week.
	 * @return The start time of the period.
	 */
	public TimeOfDayItem getPeriodStartTime() {
		return periodStartTime;
	}

	/**
	 * Getter for the period end time on the day of the week.
	 * @return The end time of the period.
	 */
	public TimeOfDayItem getPeriodEndTime() {
		return periodEndTime;
	}

	/**
	 * Prints the values of the container.
	 */
	public void printItems() {
		SchoolLogger.logger.log(
			Level.INFO,
			"************************************************");
		Item iList[] = getValidationItems();
		for (int j = 0; j < iList.length; j++) {
			if (iList[j] != null) {
				SchoolLogger.logger.log(
					Level.INFO,
					iList[j].getFieldName() + ": " + iList[j].toString());
			}
		}
	}

}
